﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using cs499.Database;

namespace cs499.Admin
{
    public partial class DeleteDepartment : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            LinkButton adminMenuButton = (LinkButton)Master.FindControl("LoginView").FindControl("AdminMenuButton");
            adminMenuButton.CssClass = "selected";
        }

        protected void DepartmentList_RowDeleted(object sender, GridViewDeletedEventArgs e)
        {
            
        }

        protected void DepartmentList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int CurrentDepartmentId = (int)HttpContext.Current.Session["CurrentDepartmentId"];
            int departmentid = (int)DepartmentList.DataKeys[e.RowIndex].Value;
            if (CurrentDepartmentId == departmentid)
            {
                HttpContext.Current.Session["CurrentDepartmentID"] = null;
                HttpContext.Current.Session["CurrentDepartmentselectedindex"] = -1;
            }

            ListOfDepartment.DeleteDepartment(ID: departmentid);
            e.Cancel = true;
            Response.Redirect("~/Admin/DeleteDepartment.aspx");
        }
    }
}